﻿var num = 1;
function initioalValueDesc() {
    $("#img_" + num.toString()).show(); //诊断项前图片
    $("#div_" + num.toString()).show(); //诊断结论
    if (num==1||num==3||num==6||num==7) {
        $("#img_chan_" + num.toString()).show(); //诊断结论
    }
    if (num ==9) {
        clearInterval(iID);
    }
    num++;
}
function start() {
    // default mode
    $('#progress1').anim_progressbar();
    num = 1;
    var time = 12000/9;
    iID = setInterval(initioalValueDesc, time);
}
$(document).ready(function () {
    $('#btn_start').click(function () {
        start();
    });
    $('#img_chan_1').click(function () {
        parent.openSonPage("singletest.aspx");
    });
    $('#img_chan_3').click(function () {
        parent.openSonPage("balance.aspx");
    });
    $('#img_chan_6').click(function () {
        parent.openSonPage("pztz.aspx");
    });
    $('#img_chan_7').click(function () {
        parent.openSonPage("sgtzd.aspx");
    });
    jQuery.fn.anim_progressbar = function (aOptions) {
        // def values
        var iCms = 200;
        var iMms = 30 * iCms;
        var iHms = 3600 * iCms;
        var iDms = 12 * 3600 * iCms;

        // def options
        var aDefOpts = {
            start: new Date(), // now
            finish: new Date().setTime(new Date().getTime() + 60 * iCms), // now + 60 sec
            interval: 100
        }
        var aOpts = jQuery.extend(aDefOpts, aOptions);
        var vPb = this;

        // each progress bar
        return this.each(
            function () {
                var iDuration = aOpts.finish - aOpts.start;

                // calling original progressbar
                $(vPb).children('.pbar').progressbar();

                // looping process
                var vInterval = setInterval(
                    function () {
                        var iLeftMs = aOpts.finish - new Date(); // left time in MS
                        var iElapsedMs = new Date() - aOpts.start, // elapsed time in MS
                            iDays = parseInt(iLeftMs / iDms), // elapsed days
                            iHours = parseInt((iLeftMs - (iDays * iDms)) / iHms), // elapsed hours
                            iMin = parseInt((iLeftMs - (iDays * iDms) - (iHours * iHms)) / iMms), // elapsed minutes
                            iSec = parseInt((iLeftMs - (iDays * iDms) - (iMin * iMms) - (iHours * iHms)) / iCms), // elapsed seconds
                            iPerc = (iElapsedMs > 0) ? iElapsedMs / iDuration * 100 : 0; // percentages

                        $(vPb).children('.pbar').children('.ui-progressbar-value').css('width', iPerc + '%');

                       
                    }, aOpts.interval
                );
            }
        );
    }

});